#!/usr/bin/env python
# *-* coding: utf-8 *-*
#
#       youtube_syncronizer
#       
#       Copyright 2009 Frederico Rodrigues Chevitarese <fchevitarese@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

from django.core.management.base import NoArgsCommand
from django.conf import settings
from django_youtube_syncronizer.utils import youtube_sync
from django_youtube_syncronizer.models import *

class Command(NoArgsCommand):
    if settings.YOUTUBE_SYNC_LANG == 'BR':
        help = u'Sincroniza os vídeos de um canal do youtube'
    else:
        help = 'Contacts Youtube and synchronizes with a user feed list.'

    def handle_noargs(self, **options):
        Feed = new_feed.objects.all()
        if Feed: 
            for channel in Feed:
                youtube_sync(channel)
        else:
            if settings.YOUTUBE_SYNC_LANG == 'BR':
                print(u'Nenhum canal cadastrado no banco.')
            else:
                print ("No feed in database")